package com.xiaotu.storage;

import java.util.Date;

import org.springframework.stereotype.Component;

import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.common.util.Constants.DataRedisKey;
import com.xiaotu.storage.converter.AConverter;
import com.xiaotu.storage.converter.ConverterFactory;
import com.xiaotu.storage.model.CacheDataModel;

import net.sf.json.JSONObject;

/**
 * @类名 TVTYStorageProcessor
 * @日期 2017年3月1日
 * @作者 高海军
 * @功能 作品天涯数据转储
 */
@Component("TVTYStorageProcessor")
public class TVTYStorageProcessor extends StarTYStorageProcessor
{
	@Override
	public String process(JSONObject target, CacheDataModel cacheData,
			Date date)
	{
		this.validateAllNotEmpty(target, "tvId", "tvName", "title", "floorHost",
				"pubDate", "click", "reply");
		
		return this.list2CSVLine(ConverterFactory.convert(target,
				new String[] { "tvId", "tvName", "title", "floorHost", "click",
						"reply", "pubDate", "timestamp" },
				new String[] { AConverter.STRING_CONVERT,
						AConverter.STRING_CONVERT, AConverter.STRING_CONVERT,
						AConverter.STRING_CONVERT, AConverter.STRING_CONVERT,
						AConverter.INTEGER_CONVERT, AConverter.DATE_CONVERT,
						AConverter.TIMESTAMP_CONVERT },
				new boolean[] { true, true, true, true, true, true, true,
						true }));
	}
	
	@Override
	protected String getRedisKey(Date date)
	{
		return DataRedisKeyUtils.getKey(DataRedisKey.TV_Tianya_YYYYMMDD, date);
	}
	
	@Override
	public String getTaskType()
	{
		return Constants.SpiderTaskType.TIANYA_TV;
	}
}
